package com.example.demo.web.vo;

import lombok.Data;
import org.springframework.beans.BeanUtils;

import com.example.demo.sys.service.bo.UserBO;

@Data
public class UserNodeVO {
    private String id;
    private String parent;
    private String name;

    public static UserNodeVO convert(UserBO userBO) {
        if (userBO == null) {
            return null;
        }
        UserNodeVO result = new UserNodeVO();
        Long pid = userBO.getPid();
        String pidstr = "";
        String id = userBO.getId().toString();
        if (pid != null && pid > 0) {
            id = pid + "." + id;
            System.out.println("id=>"+id+";pid=>"+pid);
            pidstr = pid.toString();
        } else {
            pidstr = "-1";
        }
        result.setId(id);
        result.setName(userBO.getNickname());
        result.setParent(pidstr);
        return result;
    }
}
